#!/bin/sh

cd ../boot
#nasm read_floppy.asm -o boot.bin
nasm boot.asm -o boot.bin
if [ $? -ne 0 ];then
    echo "FATAL ERROR: compile BOOT failed!"
    exit 1
fi

nasm loader.asm -o system.bin
#nasm idt_test.asm -o system.bin
#nasm paging_test2.asm -o system.bin
#nasm read_memory_info.asm -o system.bin
#nasm paging_test.asm -o system.bin
#nasm chg_pri_test_stack_switch.asm -o system.bin
if [ $? -ne 0 ];then
    echo "FATAL ERROR: compile SYSTEM failed!"
    exit 1
fi

mv -f boot.bin ../output/boot.bin
mv -f system.bin ../output/system.bin

cd ../output
# 写引导扇区的512字节
dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc
# 从第2个扇区开始，写200个扇区
dd if=system.bin of=a.img seek=1 bs=512 count=200 conv=notrunc
#dd if=test.bin of=a.img seek=1 bs=512 count=1000 conv=notrunc


# 启动bochs模拟器
# bochs -f bochsrc